package com.nguc.ngucpractice.controller;

import com.nguc.ngucpractice.common.controller.BaseController;
import com.nguc.ngucpractice.pojo.Role;
import com.nguc.ngucpractice.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

@Controller
@RequestMapping("/manage/role")
public class RoleController extends BaseController {
    @Autowired
    private RoleService roleService;

    //查询所有
    @RequestMapping("/list")
    public ModelAndView findAllRole() {
        return feedback(roleService.findAllRole());
    }

    //查询所有
    @RequestMapping("/add")
    public ModelAndView addRole(@RequestBody Map<String, String> map) {
        return feedback(roleService.addRole(map.get("roleName")));
    }

    //更新角色权限
    @RequestMapping("/update")
    public ModelAndView updateRole(@RequestBody Role role) {

        return feedback(roleService.updateRole(role));
    }
}
